/*
 * SUID.h
 *
 *  Created on: Apr 28, 2017
 *      Author: zhangjf
 */

#ifndef SRC_SUID_H_
#define SRC_SUID_H_

#include <Poco/Types.h>

using namespace Poco;

namespace util
{

typedef enum
{
	MATCH_SITE_ID = 1,
	MATCH_UNIT_ID = 2,
	MATCH_TYPE = 4,
	MATCH_IID = 8,
	MATCH_ALL = MATCH_SITE_ID | MATCH_UNIT_ID | MATCH_TYPE | MATCH_IID,
} SUID_MATCH_MODE;

typedef enum
{
	OBJECT_TYPE_INVALID = 0,
	OBJECT_TYPE_CELL,
//	OBJECT_TYPE_TASK,
	OBJECT_TYPE_CONNECTOR,
//	OBJECT_TYPE_
} OBJECT_TYPE;

//
class SUID
{
public:
	SUID();
	SUID(OBJECT_TYPE type, UInt32 iid);
	SUID(UInt16 sid, UInt16 uid, OBJECT_TYPE type, UInt32 iid);
	SUID(SUID& suid);
	virtual ~SUID();

	UInt32 getIid() const
	{
		return _iid;
	}

	void setIid(UInt32 iid = 0)
	{
		_iid = iid;
	}

	UInt16 getSiteId() const
	{
		return _siteID;
	}

	void setSiteId(UInt16 siteId = 0)
	{
		_siteID = siteId;
	}

	UInt16 getUnitId() const
	{
		return _unitID;
	}

	void setUnitId(UInt16 snitId = 0)
	{
		_unitID = snitId;
	}

	OBJECT_TYPE getType() const
	{
		return _type;
	}

	void setType(OBJECT_TYPE type = OBJECT_TYPE::OBJECT_TYPE_INVALID)
	{
		_type = type;
	}

	bool operator ==(const SUID& oRhs) const;
	bool equals(const SUID& oRhs, SUID_MATCH_MODE mMode = SUID_MATCH_MODE::MATCH_ALL) const;
	bool isEmpty() const;
	void empty();

private:
	UInt16 _siteID = 0;
	UInt16 _unitID = 0;
	OBJECT_TYPE _type = OBJECT_TYPE::OBJECT_TYPE_INVALID;
	UInt16 _reserved = 0;
	UInt32 _iid = 0;
};

} /* namespace util */

#endif /* SRC_SUID_H_ */
